﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Main.Common
{
    public static class EnumerableExtensions
    {

        public static T Locate<T>(this System.Collections.IEnumerable list)
        {
            Type searching = typeof(T);
            foreach (object o in list)
            {
                if (o == null) continue;
                Type t = o.GetType();
                if (searching.IsAssignableFrom(t))
                {
                    return (T)o;
                }
            }
            return default(T);
        }
    }
}
    //IEnumerable<IComponent>
